<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.base.myproject.client.jdbc.*" %>
<%@ page language="java" import="com.base.myproject.server.*" %>
<%@ page language="java" import="com.base.myproject.client.jdbc.DataSet" %>
<%@ page language="java" import="com.base.myproject.server.tools.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>考情异常报表</title>
<%
	String begintime = request.getParameter("beginTime");
	String endtime = request.getParameter("endTime");
	String depCode = request.getParameter("depCode");
	String manager = request.getParameter("manager");
	String depName = request.getParameter("department");
	String level = request.getParameter("level");
	String leveld = "";
	
	String where = " where 部门 like '"+depCode+"%' and 日期 between '"+begintime+"' and '"+endtime+"'";
	if(manager != null){
		if(manager.equals("正常")){
			where = where + " and isnull(处理,'')='正常'";
		}else if(manager.equals("非正常")){
			where = where + " and isnull(处理,'')<>'正常'";
		}
	} 
	if(level != null){
		if(level != ""){
			where = where + " and right(rtrim(a.员工编号),4) in (select bcode from bcode_job where employlevel in("+level+") and employstatus='在职' )";
			String levels[] = level.split(",");
			for(int i = 0;i < levels.length;i++){
				leveld += levels[i];
			}
			leveld = leveld.replace("''","、");
			leveld = leveld.substring(1,leveld.length() - 1);
		}
	}
			
	DataSetTool DST = new DataSetTool();
	String sql = "select 日期,部门,name,bname,异常状态,员工编号,处理,处理人,扣数,调整,排班,加班补休,打卡记录  from " +
	" (select * from v_exception) as a left join  " +
	" (select name,id from systeminfo) as b on a.部门 = b.id left join " +
	" (select bname,bcode from bcode) as c on right(rtrim(a.员工编号),4) = c.bcode " + where;
	DataSet ds = DST.getDataSet(sql);
	DataSet dep = DST.getDataSet("select name from systeminfo where id='"+depCode+"'");
%>
</head>
<body>
<table style="border-collapse: collapse"  border="0" width="100%" style="line-height: 120%;">
	<tr align='center'>
		<td colspan="11">
			<p align='center'><font size='4'><b>考勤异常报表</b></font></p>
		</td>
	</tr>
	<tr>
		<td align="left" colspan="11">
			<p align="left"><font size="2">查询条件：部门:<%=depName == null ? "" : depName %> | 
			雇佣级别:<%=leveld == null ? "" : leveld %> |
			时间：从<%=begintime == null ? "" : begintime %>到<%=endtime == null ? " " : endtime %> |
			处理情况：<%=manager == null ? "" : manager%></font></p>
		</td>
	</tr>
	<tr>
		<td>
			<table style="border-collapse: collapse" cellspacing="0" cellpadding="0" border="1" width="100%" bordercolordark="#CCCCCC" bordercolorlight="#CCCCCC" style="line-height: 120%;border-color:#000000;font-size:10px">
				<tr bgcolor="#e8e8e0" align="center">
					<td><font size="2">部门/分部</font></td><td><font size="2">姓名</font></td><td><font size="2">日期</font></td><td><font size="2">员工编号</font></td><td><font size="2">异常状态</font></td><td><font size="2">处理情况</font></td><td><font size="2">扣数</font></td><td><font size="2">打卡记录</font></td><td><font size="2">班次时段</font></td><td><font size="2">加班/补休/请假时段</font></td><td><font size="2">部门意见</font></td>
					</tr>
					<%
						for(int i = 0;i < ds.getRowCount();i++){
					%>
					<tr>
						<td align="center"><font size="2"><%=ds.getValue(i,"name") %></font></td>
						<td align="center"><font size="2"><%=ds.getValue(i,"bname") %></font></td>
						<td align="center"><font size="2"><%=ds.getValue(i,"日期") %></font></td>
						<td align="center"><font size="2"><%=ds.getValue(i,"员工编号") %></font></td>
						<td align="center"><font size="2"><%=ds.getValue(i,"异常状态") == null ? "" : ds.getValue(i,"异常状态") %></font></td>
						<td align="center"><font size="2"><%=ds.getValue(i,"处理") == null ? "" : ds.getValue(i,"处理") %></font></td>
						<td align="center"><font size="2"><%=ds.getValue(i,"扣数") == null ? "" : ds.getValue(i,"扣数") %></font></td>
						<td><font size="2">&nbsp;<%=ds.getValue(i,"打卡记录") == null ? "" : ds.getValue(i,"打卡记录") %></font></td>
						<td><font size="2">&nbsp;<%=ds.getValue(i,"排班") == null ? "" : ds.getValue(i,"排班") %></font></td>
						<td><font size="2">&nbsp;<%=ds.getValue(i,"加班补休") == null ? "" : ds.getValue(i,"加班补休")%></font></td>
						<td></td>
					</tr>
				<%} %>	
			</table>
		</td>
	</tr>
</table>
<br></br>
<p align="center">部门主管:______________________ 人力资源部：______________________ 核查人签名:______________________</p>
</body>
</html>